
import request from '@/router/axios';

export const orderTree = () => { // 查询订单左侧树
  return request({
    url: '/api/blade-order/orderInfo/leftTree',
    method: 'get'
  })
}

export const orderList = (userid, current, size, params, orderStatus, date) => { // 查询订单列表
  return request({
    url: '/api/blade-order/orderInfo/list',
    method: 'post',
    data: {
      userid,
      size,
      current,
      params,
      orderStatus,
      startTime: date != ''  ? date[0] : '',
      endTime: date  != '' ? date[1] : ''
    }
  })
}

export const queryOrderStatus = () => { // 查询订单状态
  return request({
    url: '/api/blade-public/dictCommon/queryDict2',
    method: 'post',
    data:{
      dictKey: "订单状态"
    }
  })
}


export const saveOrder = (form) => { // 保存订单
  return request({
    url: '/api/blade-order/orderInfo/save',
    method: 'post',
    data:form
  })
}

export const editOrder = (form) => { // 保存订单
  return request({
    url: '/api/blade-order/orderInfo/edit',
    method: 'post',
    data:form
  })
}

export const orderDetail = (id) => { // 查询单个订单
  return request({
    url: `/api/blade-order/orderInfo/detail/${id}`,
    method: 'get'
  })
}

export const deleteProduct = (productId,id) => { // 删除产品
  return request({
    url: '/api/blade-order/orderInfo/productDelete',
    method: 'post',
    data: {
      productId,
      id
    }
  })
}

export const deleteOrder = (id) => { // 删除订单
  return request({
    url: `/api/blade-order/orderInfo/delete/${id}`,
    method: 'get'
  })
}


export const queryCustList = (typeId,fullname) => { // 选择客户接口
  return request({
    url: '/api/blade-custom/custInfo/custName',
    method: 'post',
    data: {
      fullname,
      typeId
    }
  })
}

export const queryLinker = (custid) => { // 根据客户id查询所有联系人
  return request({
    url: '/api/blade-custom/tCustLinker/list1',
    method: 'get',
    params: {
      custid
    }
  })
}

export const queryUser= () => { // 根据客户id查询所有联系人
  return request({
    url: '/api/blade-public/bladeUser/currentUser',
    method: 'post'
  })
}


export const queryProduct= (productName, productModel, productType, typeId) => { // 根据条件查询产品列表
  return request({
    url: '/api/blade-product/product/list',
    method: 'post',
    data: {
      productName,
      productModel,
      productType,
      typeId
    }
  })
}

export const addOrderProduct= (id,productTotalAmount,productListDtos, custId, linkerIds) => { // 保存订单产品信息
  return request({
    url: '/api/blade-order/orderInfo/productInsert',
    method: 'post',
    data: {
      id:Number(id),
      productTotalAmount,
      productListDtos,
      custId,
      linkerIds
    }
  })
}


export const saveOrderProduct= (id,productTotalAmount,productListDtos, custId, linkerIds) => { // 保存订单产品信息
  return request({
    url: '/api/blade-order/orderInfo/orderProduct',
    method: 'post',
    data: {
      id:Number(id),
      productTotalAmount,
      productListDtos,
      custId,
      linkerIds
    }
  })
}

export const detailTrade= (orderId) => { // 查询贸易信息
  return request({
    url: `/api/blade-order/orderTrade/detailTrade/${orderId}`,
    method: 'get'
  })
}

export const saveTrade= (form) => { // 保存贸易信息
  return request({
    url: `/api/blade-order/orderTrade/editTrade`,
    method: 'post',
    data: form
  })
}


export const queryPriceOptions= () => { // 查询价格条款
  return request({
    url: '/api/blade-public/dictCommon/queryDict2',
    method: 'post',
    data:{
      dictKey: "价格条款"
    }
  })
}

export const queryReceivablesOptions= () => { // 查询收汇方式
  return request({
    url: '/api/blade-public/dictCommon/queryDict2',
    method: 'post',
    data:{
      dictKey: "收汇方式"
    }
  })
}

export const queryFreightOptions= () => { // 查询收汇方式
  return request({
    url: '/api/blade-public/dictCommon/queryDict2',
    method: 'post',
    data:{
      dictKey: "货运方式"
    }
  })
}

export const exportExcel= (id, type) => { // 导出
  return request({
    url: `/api/blade-order/orderInfo/export/${id}/${type}`,
    method: 'get',
    responseType: 'blob'
  })
}

export const pdfExport= (id, type) => { // 导出
  return request({
    url: `/api/blade-order/orderInfo/pdfExport/${id}/${type}`,
    method: 'get',
    responseType: 'blob'

  })
}

export const getUser = (userId) => { // 根据userid查询个人信息
  return request({
    url: `/api/blade-public/bladeUser/userById`,
    method: 'get',
    params:{
      userId
    }
  })
}

export const findCustByWeek = () => { // 最近选择客户
  return request({
    url: `/api/blade-order/orderInfo/findCustByWeek`,
    method: 'get'
  })
}

export const uploadOrder = (data) => {
  return request({
    url: '/api/blade-file/file/upload',
    method: 'post',
    headers: {
      "Content-Type": "multipart/form-data"
    },
    data
  })
}



